#include <iostream>
#include <string>

bool is_valid_sequence(std::string sequence) {
    while (sequence.find("()") != std::string::npos || sequence.find("[]") != std::string::npos ||
           sequence.find("{}") != std::string::npos || sequence.find("<>") != std::string::npos) {
        size_t pos;
        if ((pos = sequence.find("()")) != std::string::npos) sequence.erase(pos, 2);
        if ((pos = sequence.find("[]")) != std::string::npos) sequence.erase(pos, 2);
        if ((pos = sequence.find("{}")) != std::string::npos) sequence.erase(pos, 2);
        if ((pos = sequence.find("<>")) != std::string::npos) sequence.erase(pos, 2);
    }
    return sequence.empty();
}

int main() {
    std::string a;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> a;
    std::cout << (is_valid_sequence(a) ? "true" : "false") << std::endl;
    return 0;
}





